/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            auId:'',
            affiliateCommissionManages: {}
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('affiliateCommissionManage', 'switch', function (_data) {
                $that.auId = _data.auId;
                $that._loadDataDetailAffiliateCommission(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('affiliateCommissionManage', 'notify',
                function (_data) {
                    $that._loadDataDetailAffiliateCommission(DEFAULT_PAGE, DEFAULT_ROWS);
                });
            vc.on('affiliateCommissionManage', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    $that._loadDataDetailAffiliateCommission(_currentPage, DEFAULT_ROWS);
                });
        },
        methods: {
            _loadDataDetailAffiliateCommission: function (_page, _row) {
                let param = {
                    params: {
                        auIdContain2Level: $that.auId,
                        page: _page,
                        row: _row
                    }
                };

                //发送get请求
                vc.http.apiGet('/affiliateCommission.listAffiliateCommission',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.affiliateCommissionManages = _json.data;
                        vc.emit('affiliateCommissionManage', 'paginationPlus', 'init', {
                            total: _json.records,
                            dataCount: _json.total,
                            currentPage: _page
                        });
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            _level: function (_state) {
                if(_state == "1"){
                    return "一级"
                }
                if(_state == "2"){
                    return "二级"
                }
            },
            _state: function (_state) {
                if(_state == "0"){
                    return "待结算"
                }
                if(_state == "1"){
                    return "已结算"
                }
                if(_state == "2"){
                    return "已取消"
                }
            },
        }
    });
})(window.vc);
